DBlock< Type > Class Template Reference

#include <block.h>

List of all members.

Public Member Functions

 DBlock (int size, void(*err_function)(char *)=NULL)
 ~DBlock ()
Type * New ()
void Delete (Type *t)

Private Types

typedef DBlock::block_item_st block_item
typedef DBlock::block_st block

Private Attributes

int block_size
blockfirst
block_itemfirst_free
void(* error_function )(char *)

Classes

union  block_item_st
struct  block_st


Detailed Description

template<class Type>
class DBlock< Type >

Definition at line 202 of file block.h.


Member Typedef Documentation

template<class Type>
typedef struct DBlock::block_st DBlock< Type >::block [private]

template<class Type>
typedef union DBlock::block_item_st DBlock< Type >::block_item [private]


Constructor & Destructor Documentation

template<class Type>
DBlock< Type >::DBlock ( int  size,
void(*)(char *)  err_function = NULL 
) [inline]

Definition at line 209 of file block.h.

00209 { first = NULL; first_free = NULL; block_size = size; error_function = err_function; }

template<class Type>
DBlock< Type >::~DBlock (  )  [inline]

Definition at line 212 of file block.h.

00212 { while (first) { block *next = first -> next; delete first; first = next; } }


Member Function Documentation

template<class Type>
void DBlock< Type >::Delete ( Type *  t  )  [inline]

Definition at line 237 of file block.h.

00238         {
00239                 ((block_item *) t) -> next_free = first_free;
00240                 first_free = (block_item *) t;
00241         }

template<class Type>
Type* DBlock< Type >::New (  )  [inline]

Definition at line 215 of file block.h.

00216         {
00217                 block_item *item;
00218 
00219                 if (!first_free)
00220                 {
00221                         block *next = first;
00222                         first = (block *) new char [sizeof(block) + (block_size-1)*sizeof(block_item)];
00223                         if (!first) { if (error_function) (*error_function)("Not enough memory!"); exit(1); }
00224                         first_free = & (first -> data[0] );
00225                         for (item=first_free; item<first_free+block_size-1; item++)
00226                                 item -> next_free = item + 1;
00227                         item -> next_free = NULL;
00228                         first -> next = next;
00229                 }
00230 
00231                 item = first_free;
00232                 first_free = item -> next_free;
00233                 return (Type *) item;
00234         }


Member Data Documentation

template<class Type>
int DBlock< Type >::block_size [private]

Definition at line 259 of file block.h.

template<class Type>
void(* DBlock< Type >::error_function)(char *) [private]

template<class Type>
block* DBlock< Type >::first [private]

Definition at line 260 of file block.h.

template<class Type>
block_item* DBlock< Type >::first_free [private]

Definition at line 261 of file block.h.


The documentation for this class was generated from the following file:
Generated on Sun Oct 26 18:22:20 2008 for maxflow-v3.0 by  doxygen 1.4.7